home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12457 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.spies.com!usenet
  2. From: Erik Max Francis <max@alcyone.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: routine for yesterday's date
  5. Date: Sun, 31 Mar 1996 20:13:18 -0800
  6. Organization: Alcyone Systems
  7. Message-ID: <315F57DE.30A14E31@alcyone.com>
  8. References: <315c4d0f.19874776@ottnews.shl.com> <1996Mar30.043002.19054@sq.com> <Dp3B56.FKI@alisa.org>
  9. NNTP-Posting-Host: newton.alcyone.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.01 (X11; I; Linux 1.2.13 i486)
  14.  
  15. John J. Rushford wrote:
  16.  
  17. > Why bother with mktime() when it is so much easier to use the following and
  18. > you don't have to bother with errors gotten from x.tm_day--;
  19. >     long ticks
  20. >     struct tm * dt;
  21. >     time(&ticks);
  22. >     /* 86400 seconds in a day */
  23. >     ticks -= 86400
  24. >     dt = localtime (&ticks);
  25.  
  26. That would be great if the time_t value were measured in seconds elapsed since
  27. some reference time.  Then a change in 86 400 s would represent one day.
  28.  
  29. However, it doesn't.  ANSI C 1990, 7.12.2.4:
  30.  
  31.     The `time' function determines the current calendar time.  The encoding 
  32.     of the value is unspecified.
  33.  
  34. -- 
  35. Erik Max Francis &tSftDotIotE && http://www.alcyone.com/max && max@alcyone.com
  36. San Jose, California, U.S.A. && 37 20 07 N 121 53 38 W && the 4th R is respect
  37. H.3`S,3,P,3$S,#$Q,C`Q,3,P,3$S,#$Q,3`Q,3,P,C$Q,#(Q.#`-"C`- && 1love && folasade
  38. Omnia quia sunt, lumina sunt. && Dominion, GIGO, GOOGOL, Omega, Psi, Strategem
  39. "Out from his breast/his soul went to seek/the doom of the just." -- _Beowulf_
  40.